Engine: Inline comments on <% end %> on output blocks produce invalid Ruby#1363
Merged
marcoroth merged 7 commits intomarcoroth:mainfrom Mar 11, 2026
Merged
Engine: Inline comments on <% end %> on output blocks produce invalid Ruby#1363marcoroth merged 7 commits intomarcoroth:mainfrom
<% end %> on output blocks produce invalid Ruby#1363marcoroth merged 7 commits intomarcoroth:mainfrom
Conversation
c0be71f to
e459c83
Compare
<% end %> on output blocks produce invalid Ruby
e459c83 to
0166a9b
Compare
f01fff4 to
33b7576
Compare
marcoroth
reviewed
Mar 11, 2026
Co-authored-by: Marco Roth <marco.roth@intergga.ch> Signed-off-by: Joel Hawksley <joelhawksley@github.com>
marcoroth
approved these changes
Mar 11, 2026
Owner
marcoroth
left a comment
There was a problem hiding this comment.
Awesome, thank you @joelhawksley! 🙏🏼
marcoroth
added a commit
that referenced
this pull request
Mar 11, 2026
…1365) This pull request updates the Ruby CLI to show the compiled source when the `compile` subcommand produced invalid Ruby **Before** ``` ❯ bin/herb compile test.html.erb Compiled template produced invalid Ruby: - unexpected end-of-input, assuming it is closing the parent top level context (line 4) - expected a matching `)` (line 5) - unexpected end-of-input; expected a `)` to close the arguments (line 4) ``` **After** ``` ❯ bin/herb compile test.html.erb __herb = ::Herb::Engine; _buf = ::String.new; _buf << __herb.h((render Foo.new do; _buf << 'hello'.freeze; end # comment)) _buf << ' '.freeze; _buf.to_s Compiled template produced invalid Ruby: - unexpected end-of-input, assuming it is closing the parent top level context (line 4) - expected a matching `)` (line 5) - unexpected end-of-input; expected a `)` to close the arguments (line 4) ``` Inspired while working on #1363
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version
herb 0.8.10 (commit
3a36f815b05b)Summary
When
<% end # comment %>closes a block opened inside a<%= %>output tag, Herb appends the closing))after the comment text in compiled Ruby. Since#starts a Ruby comment, the))become part of the comment, leaving__herb.h((unclosed.Minimal reproduction
Actual compiled Ruby (broken)
The
))after# commentis commented out — parens never close.Expected
The
))should be placed before the comment, or the comment should be stripped:Prism parse errors
Scope
<% end # ... %>closing a block started in<%= %>(where Herb wraps in__herb.h((...)))<% end # ... %>inside non-output<% %>tags — no wrapping parens, so comment is harmlessWorkaround
Remove inline comments from
endtags that close output-tag blocks.